//
//  IManager+ModuleTicketOrderInfo.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-11-29.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+ModuleTicketOrderInfo.h"
#import "NSString+NSString_Ex_.h"
#import "FrameworkRelativeDefines.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "RCTrainOrderDetailInfoDataModel.h"
#import "GloableEngineService.h"
#import "RCFeedbackDataModel.h"

@implementation IManager(ModuleTicketOrderInfo)

-(int64_t)requestTrainOrderInfo:(NSString *)fromCity withToCity:(NSString *)toCity withTime:(NSString *)time withTrainCode:(NSString *)trainCode withDelegate:(id<IManagerDelegate>)delegate{
    if ([NSString stringIsNullOrEmpty:fromCity]||[NSString stringIsNullOrEmpty:toCity]||[NSString stringIsNullOrEmpty:time]||[NSString stringIsNullOrEmpty:trainCode]) {
        return kInvalidRequestId;
    }
    
    NSString *bduss = [GloableEngineService sharedInstance].bduss;
    NSString *urlSuffix = [NSString stringWithFormat:kTrainOrderDetailInfoPrefix,fromCity,toCity,time,trainCode,bduss];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCTrainOrderDetailInfoDataModel class]
                                                     withDataDelegate:delegate];
}

-(int64_t)commitTrainOrderInfo:(NSDictionary *)dictData withDelegate:(id<IManagerDelegate>)delegate{
    
    if (nil == dictData) {
        return kInvalidRequestId;
    }
    
    NSString *urlSuffix = kCommitTrainOrderPrefix;
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncPostData:url postValues:dictData postDataList:nil userInfo:nil withDataParseClass:[RCFeedbackDataModel class] withDataDelegate:delegate];
}



-(int64_t)requestFlyOrderInfo:(NSString *)fromCity withToCity:(NSString *)toCity withFromDate:(NSString *)date withAirLine:(NSString *)airLine withDelegate:(id<IManagerDelegate>)delegate{
    
    
    if ([NSString stringIsNullOrEmpty:fromCity]||[NSString stringIsNullOrEmpty:toCity]||[NSString stringIsNullOrEmpty:date]||[NSString stringIsNullOrEmpty:airLine]) {
        return kInvalidRequestId;
    }
    
    NSString *bduss = [GloableEngineService sharedInstance].bduss;
    NSString *urlSuffix = [NSString stringWithFormat:kFlyOrderDetailInfoPrefix,fromCity,toCity,date,airLine,bduss];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCFlyOrderDetailInfoDataModel class]
                                                     withDataDelegate:delegate];
    
}

-(int64_t)commitFlyOrderInfo:(NSDictionary *)dictData withDelegate:(id<IManagerDelegate>)delegate{
    
    if (nil == dictData) {
        return kInvalidRequestId;
    }
    
    NSString *urlSuffix = kCommitFlyOrderPrefix;
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncPostData:url postValues:dictData postDataList:nil userInfo:nil withDataParseClass:[RCFeedbackDataModel class] withDataDelegate:delegate];
}

@end
